<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Javascript基础</title>
</head>
<body>
    <script>
        function login(){
            var name = document.getElementsByName("username")[0].value;
            var password = document.getElementsByName("password")[0].value;
            if (name == "" || name == null || password == "" || password == null){
                window.alert("请输入用户名或密码")
            } else if (name == "rabbit" && password == "love"){
                window.alert("登录成功")
            } else {
                window.alert("用户名或密码错误")
            }
        }
    </script>
    <h1>祝大家牛年大吉！</h1>
    <div>
        <form action="demo_form.php">
        用户名: <input type="text" name="username" maxlength="10"><br>
        密码: <input type="password" name="password" maxlength="10"><br>
        <input type="button" id="sub"  onclick="login()" value="确定">
        </form>

    </div>
</body>
</html>